<template>
    <div id="left-top-bar" style="width: 100%; height: 400px"></div>
</template>
<script lang="ts">
import { defineComponent, onMounted } from 'vue'

import echarts, { option } from './constant'
import { peopleChange } from '@/views/screens/PovertyData/constant'

export default defineComponent({
    name: 'LeftTopBar',
    setup() {
        const constant = {
            option
        }
        onMounted(() => {
            let { option } = constant

            option.series[0].data = peopleChange.map((el: any) => el.incidenceRate)
            option.xAxis.data = peopleChange.map((item: any) => item.year)
            option.series[1].data = peopleChange.map((item: any) => item.oldCount)
            echarts.init(document.getElementById('left-top-bar')).setOption(option)
        })

        return {
            ...constant
        }
    }
})
</script>
